/*
 * Copyright 2016 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.channel;

import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.FutureListener;

import java.net.ConnectException;
import java.net.SocketAddress;

public interface ChannelOutboundInvoker {

    //绑定
    ChannelFuture bind(SocketAddress localAddress);

    //连接
    ChannelFuture connect(SocketAddress remoteAddress);

    //连接
    ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress);

    //断开连接
    ChannelFuture disconnect();

    //关闭
    ChannelFuture close();

    //取消注册
    ChannelFuture deregister();

    //绑定
    ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise);

    //连接
    ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise);

    //连接
    ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise);

    //断开连接
    ChannelFuture disconnect(ChannelPromise promise);

    //关闭
    ChannelFuture close(ChannelPromise promise);

    //取消注册
    ChannelFuture deregister(ChannelPromise promise);

    //读
    ChannelOutboundInvoker read();

    //写
    ChannelFuture write(Object msg);

    //写
    ChannelFuture write(Object msg, ChannelPromise promise);

    //刷新
    ChannelOutboundInvoker flush();

    //写并刷新
    ChannelFuture writeAndFlush(Object msg, ChannelPromise promise);

    //写并刷新
    ChannelFuture writeAndFlush(Object msg);

    //新建一个Promise
    ChannelPromise newPromise();

    //
    ChannelProgressivePromise newProgressivePromise();

    //新建一个执行成功的回调
    ChannelFuture newSucceededFuture();

    //新建一个执行失败的回调
    ChannelFuture newFailedFuture(Throwable cause);

    //返回一个Promise
    ChannelPromise voidPromise();
}
